<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="<%=basePath%>">
<title>代理商</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.4.5/angular.min.js"></script>
<style>
.main_div {
	min-width: 1000px
}

.pageChange {
	float:right;
	color: #337ab7;
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>


</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>退货管理</span>
					</div>
					<form class="form-inline" action="" method="post"
						style="margin-top: 30px;margin-left: 20px">						
						<input style="display:none" value="7" id="pageCount" name="pageCount" /> 						
						<div class="form-group">
							<label for="orderCode"> 订单编号:</label> <input type="text"
								class="form-control" name="" id="orderCode" placeholder="">
						</div>
						<div class="form-group">
							<label for="ProductName"> 顾客名称:</label> <input type="text"
								class="form-control" id="userName" placeholder="">
						</div>
						<div class="form-group">
							<label for="userName"> 顾客电话:</label> <input type="text"
								class="form-control" name="phone" id="phone" placeholder="">
						</div>						
						<input onclick="selectinfo()" class="btn btn-primary" type="button" value="立即查询" />
					</form>
				</div>
				<div class="force-overflow1-1">
					<table class="table table-condensed table-bordered table-hover"
						show-filter="true" style="text-align: center" id="showtable">
						<tr style="background-color: #59c7d2">
							<th style="text-align: center">序号</th>
							<th style="text-align: center">订单编号</th>
							<th style="text-align: center">订单价格</th>
							<th style="text-align: center">送货地址</th>
							<th style="text-align: center">联系人</th>
							<th style="text-align: center">电话</th>
							<th style="text-align: center">理由</th>
							<th style="text-align: center">留言</th>
							<th style="text-align: center">退换时间</th>
							<th style="text-align: center">立即处理</th>
						</tr>
					</table>
					<div class="pageChange">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页</em>
						<em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button type="submit" class="btn btn-primary"
							onclick="searchPage()">搜索</button>
					</div>
				</div>
			</div>
		</section>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		selectinfo();
	})

	function selectinfo() {
	   var URL = document.location.toString();
			var sperIDs = URL.split("=")[1];
		var orderFormId = $("#orderCode").val();
		var phone = $("#phone").val();
		var userName = $("#userName").val();
		var pageNum = $("#pageNum").html();
		var pageCount=$("#pageCount").val();
		if (orderFormId == "") {
			orderFormId = null;
		}
		if (phone == "") {
			phone = null;
		}
		if (userName == "") {
			userName = null;
		}
		$.post(urls+"orderFormAction/userReturn",
			{
			   superId:sperIDs,
				orderFromId : orderFormId,
				userPhone : phone,
				userName : userName,
				pageCount :pageCount,
				pageNum : pageNum
			},
			function(data) {
				if (data) {
				
				    var totalpage = data.totalpage;
					var orderlist = data.orderlist;
					var table = $("#showtable");
					$("tr").remove(".addtr");
					for (var i = 0; i < orderlist.length; i++) {
						var append = "<tr class='addtr'><td>" + (i + 1) + "</td>"+
						    "<td >" + orderlist[i].orderFormId + "</td>" +
							"<td>" + orderlist[i].totalMoney + "</td>"+
							"<td>" + orderlist[i].address + "</td>" +
							"<td>" + orderlist[i].oreturn.userName + "</td>"+
							"<td>" + orderlist[i].oreturn.userPhone + "</td>"+
							"<td>" + orderlist[i].oreturn.returnCause + "</td>" +
							"<td>" + orderlist[i].oreturn.returnContent + "</td>"+
							"<td>" + orderlist[i].oreturn.returnTime + "</td>" +
							"<td><input onclick='returninfo(this)' id="+orderlist[i].orderFormId +" type='button' class='btn btn-primary' value='处理退货' /></td></tr>";
						table.append(append);
					}
					 $("#totalpage").html(totalpage);
				}
			}
			, "json"
		)
	}
	   function returninfo(e){//退货	    
	     $.post(urls+"orderFormAction/disposeReturn",
	      {
	      orderFormID:e.id
	      },
	      function(res){
	      if(res){
	       alert("处理成功")
	        e.value = "已处理"
	        e.disabled ="true"
	      }else{
	      alert("处理失败")
	      }
	      }
	     )
	   }

	
</script>
</html>
